@section('title')
{{{ $seo->title or 'Viewing Product '.$product->name }}}
@endsection

@section('description')
{{{ $seo->description or 'My great product'}}}
@endsection

@section('keywords')
{{{ $seo->keywords or 'default, keywords, for, my, product' }}}
@endsection

@section('scripts')
{{ HTML::script('js/starrr.js') }}
<script type="text/javascript">
    $(function(){
      // Bind the change event for the star rating - store the rating value in a hidden field
      $('.starrr').on('starrr:change', function(e, value){
    	  $('#ratings-hidden').val(value);
      });
    });
  </script>
@stop

@section('content')
<div class="row">
	<div class="col-md-3">
		@include('partial.sidebar.category', array('categories' => $categories, 'current' => 0))
	</div>
	
	<div class="col-md-9">
		<div class="thumbnail">
			<img src="http://placehold.it/820x320" alt="">
			<div class="caption-full">
				<h4 class="pull-right">${{ number_format($product->pricing, 2) }}</h4>
				<h4><a href="{{ url('products/' . $product->id) }}">{{ $product->name }}</a></h4>
				<p>{{ $product->short_description }}</p>
				<p>{{ $product->long_description }}</p>
				<p>
                	<span class="glyphicon glyphicon-tag"></span><a href="#">tag 1</a>
                	<span class="glyphicon glyphicon-tag"></span><a href="#">tag 2</a>
                </p>
			</div>
			<div class="ratings">
				<p class="pull-right">{{ $product->rating_count }} đánh giá</p>
				<p>
					@for ($i = 1; $i <= 5 ; $i++) 
						<span class="glyphicon glyphicon-star{{ ($i <= $product->rating_cache) ? '' : '-empty' }}"></span>
					@endfor 
					{{ number_format($product->rating_cache, 1) }} điểm
				</p>
			</div>
		</div>
		
		<div class="well" id="reviews-anchor">
			<div class="row">
				<div class="col-md-12">
					@if (Session::get('errors'))
						<div class="alert alert-danger alert-dismissible" role="alert">
						  	<button type="button" class="close" data-dismiss="alert">
						  		<span aria-hidden="true">&times;</span>
						  		<span class="sr-only">Close</span>
						  	</button>
						  	{{ HTML::ul($errors->all()) }}
						</div>
					@endif 
					@if (Session::has('review_posted'))
						<div class="alert alert-success alert-dismissible" role="alert">
							<button type="button" class="close" data-dismiss="alert">
						  		<span aria-hidden="true">&times;</span>
						  		<span class="sr-only">Close</span>
						  	</button>
							<h5>Your review has been posted!</h5>
						</div>
					@endif 
				</div>
			</div>
			
			<div class="row">
				<div class="col-md-12">
					{{ Form::open() }} 
					{{ Form::hidden('rating', null, array('id'=>'ratings-hidden')) }} 
					{{Form::textarea('comment', null, array(
						'rows'=>'5',
						'class'=>'form-control',
						'placeholder' => 'Enter your review here...'
					)) }}
					<div class="text-right">
						<div class="stars starrr" data-rating="{{ Input::old('rating', 0) }}"></div>
						<button class="btn btn-success" type="submit">Save</button>
					</div>
					{{ Form::close() }}
				</div>
			</div>

			@foreach ($reviews as $review)
			<hr>
			<div class="row">
				<div class="col-md-12">
					@for ($i=1; $i <= 5 ; $i++) <span
						class="glyphicon glyphicon-star{{ ($i <= $review->rating) ? '' : '-empty'}}"></span>
					@endfor 
					{{ $review->user ? $review->user->name : 'Anonymous' }} 
					<span class="pull-right">{{ $review->timeago }}</span>
					<p>{{{ $review->comment }}}</p>
				</div>
			</div>
			@endforeach 
			{{ $reviews->links() }}
		</div>
	</div>

</div>
@stop  
